package com.example.demo.order.dto.response;

import com.example.demo.order.enums.OrderStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @ClassName OrderResponse
 * @Description
 * @Author MingChang.Wei
 * @Date 2025/8/8
 **/
@Data
@Schema(description = "订单响应结果")
public class OrderResponse {

    @Schema(description = "订单ID", example = "1")
    private Long id;

    @Schema(description = "订单编号", example = "ORD20231026001")
    private String orderNo;

    @Schema(description = "用户名", example = "admin")
    private String username;

    @Schema(description = "商品ID", example = "2001")
    private Long productId;

    @Schema(description = "商品名称", example = "测试商品A")
    private String productName;

    @Schema(description = "购买数量", example = "2")
    private Integer quantity;

    @Schema(description = "商品单价", example = "99.99")
    private BigDecimal price;

    @Schema(description = "订单总金额", example = "199.98")
    private BigDecimal totalAmount;

    @Schema(description = "订单状态：1-已创建，2-已支付，3-已取消，4-已退款，5-已超时")
    private Integer status;

    @Schema(description = "状态描述", example = "已创建")
    private String statusDesc; // 新增状态描述字段，方便前端展示

    @Schema(description = "支付时间")
    private LocalDateTime payTime;

    @Schema(description = "退款时间")
    private LocalDateTime refundTime;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    // 状态描述转换方法（可在 Service 层或 Controller 层处理）
    public void setStatusDesc() {
        this.statusDesc = OrderStatusEnum.getDescByCode(status);
    }
}
